package com.creatapark.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import com.creatapark.vo.ParkCarByTimeVo;

@Mapper
public interface ParkCarByTimeMapper {
    @Results({
        @Result(property = "day",column = "day"),
        @Result(property = "hour",column = "hour"),
        @Result(property = "amount",column = "amount")
})

@Select("select m.day,m.hour,count(*) amount from (select t.*, date_format(in_time, '%Y-%m-%d') day, date_format(in_time, '%H') hour from t_car_inout_data t where t.in_time >= #{staTime} and t.in_time <= #{endTime} and park_id=#{parkId}) m group by m.day,m.hour order by m.day,m.hour asc")
    List<ParkCarByTimeVo> getCountParkCarByTime(@Param("staTime") String staTime, @Param("endTime") String endTime, @Param("parkId") Long parkId);
    
}